package java8stream;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.commons.lang3.tuple.Triple;
import org.junit.Test;

public class STest {

	@Test
	public void test2() {
		Person person = new Person();
		List<Triple<String, Integer, Integer>> list = person.getData(100);
		  list.stream()
		.collect(Collectors.groupingBy(Triple::getRight))
		.values()
		.stream()
		.map(item -> item.stream()
						 .sorted((x,y) -> x.getMiddle().compareTo(y.getMiddle()))
						 .collect(Collectors.toList()))
		.map(value -> {
			Map<String, Object> ms = new HashMap<>();
			ms.put("type", value.get(0).getRight());
			ms.put("data", value);
			return ms;})
		.collect(Collectors.toList()).forEach(System.out::println);
	}
	
}
